package com.atguigu.day02;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

public class Flink05_Source_Collection {
    public static void main(String[] args) throws Exception {
        //1.获取流的执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //并行度设置为1
        env.setParallelism(1);

        //TODO 从集合获取数据
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        DataStreamSource<Integer> streamSource = env.fromCollection(list);

        //TODO 从元素中获取数据 通常在测试环境下用
        DataStreamSource<Integer> streamSource1 = env.fromElements(1, 2, 3, 4, 5);


//        streamSource.print();
        streamSource1.print();
        env.execute();
    }
}
